package com.yc.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yc.bean.TestScoreLevel;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface TestScoreLevelDao extends BaseMapper<TestScoreLevel> {
    
    /**
     * 根据测评ID查询所有评级标准
     */
    @Select("SELECT * FROM testScoreLevels WHERE testId = #{testId} ORDER BY minScore ASC")
    List<TestScoreLevel> selectByTestId(@Param("testId") Long testId);
    
    /**
     * 根据测评ID和分数查询对应的评级
     */
    @Select("SELECT * FROM testScoreLevels " +
            "WHERE testId = #{testId} AND #{score} >= minScore AND #{score} <= maxScore " +
            "LIMIT 1")
    TestScoreLevel selectByTestIdAndScore(@Param("testId") Long testId, @Param("score") Integer score);
    
    /**
     * 根据测评ID和维度ID查询评级标准
     */
    @Select("SELECT * FROM testScoreLevels " +
            "WHERE testId = #{testId} AND dimensionId = #{dimensionId} " +
            "ORDER BY minScore ASC")
    List<TestScoreLevel> selectByTestIdAndDimensionId(@Param("testId") Long testId, @Param("dimensionId") Long dimensionId);
} 